<include file="Public:header" />

<script type="text/javascript">
var rowtypedata = [
    [[1,'<input type="text" class="txt" name="newTopCateOrder[]" value="0" />', 'td25'], [5, '<input name="newTopCateName[]" value="" size="20" type="text" class="txt" /><a href="#" title="{$Think.lang.delete_current_row}" onclick="delTopCate(this)">{$Think.lang.delete}?</a>']],
    [[1,'<input type="text" class="txt" name="newCateOrder[@][]" value="0" />', 'td25'], [5, '<div class="board"><input name="newCateName[@][]" value="" size="20" type="text" class="txt" /><a href="#" title="{$Think.lang.delete_current_row}" onclick="delSubCate(this)">{$Think.lang.delete}?</a></div>']],
    [[1,'<input type="text" class="txt" name="newCateOrder[@][]" value="0" />', 'td25'], [5, '<div class="childboard"><input name="newCateName[@][]" value="" size="20" type="text" class="txt" /><a href="#" title="{$Think.lang.delete_current_row}" onclick="delSubCate(this)">{$Think.lang.delete}?</a></div>']],
];
</script>

<script type="text/javascript">
function resync(){
    var tips = '{$Think.lang.syncing_categories}';
    var message = '<h1 class="f14">'+tips+'</h1>';
    var postUrl = '__URL__/synchronise';
    $.blockUI({
        message: message,
    });
    $.post(postUrl, function(data){
        setTimeout(reload, 3000);

    });
};
function reload(){
    $.unblockUI();
    window.location.href = '__URL__/manage';
}
</script>


<div class="container" id="cpcontainer">
    <h3>{$Think.lang.manage_categories}</h3>
    <p class="tips">{$Think.lang.manage_categories_tips}</p>
    <p class="tips"><input id="resync" type="button" class="btn" value="{$Think.lang.re_sync_categories}"  onclick="resync();" /></p>
    <form name="cpform" action="__URL__/manage" method="post">
    <input type="hidden" name="op" value="save" />
    <table class="tb tb2">
        <tr>
        	<th width="12%">{$Think.lang.display_order}</th>
        	<th width="40%">{$Think.lang.category_name}</th>
            <th width="12">{$Think.lang.category_question_count}</th>
        	<th width="16%">{$Think.lang.category_moderators}</th>
        	<th>{$Think.lang.actions}</th>
            <th width="5%">{$Think.lang.visible}</th>
        </tr>
        <volist name="categoryList" id="vo">
        <switch name="vo.level">
        <case value="1">
        <tr class="item">
        	<td class="td25"><input type="text" class="txt" name="cateOrder[{$vo.category_id}]" value="{$vo.display_order}" /></td>
            <td><div class="parentboard"><input type="text" name="cateName[{$vo.category_id}]" value="{$vo.name}" class="txt" /></div><div class="boardattr"></div></td>
            <td>{$vo.question_count}</td>
            <td>
                <notempty name="vo.moderators">
                <volist name="vo.moderators" id="sub" mod="2">
                    <eq name="mod" value="0">,&nbsp;&nbsp;</eq><a href="{$sub.user_id|format_user_url=$sub['username']}" target="_blank">{$sub.username}</a>
                </volist>
                <else/>
                {$Think.lang.no_moderator}
                </notempty>
            </td>
            <td>
                <a class="act" href="__URL__/moderator/category_id/{$vo.category_id}" title="{$Think.lang.manage_moderators}">{$Think.lang.category_moderators}</a>
                <a class="act" href="__URL__/edit/category_id/{$vo.category_id}">{$Think.lang.edit}</a>
                <a class="act" href="__URL__/delete/category_id/{$vo.category_id}">{$Think.lang.delete}</a>
            </td>
            <td><input type="checkbox" name="cateStatus[{$vo.category_id}]" value="1" <if condition="$vo.status eq '1'">checked</if> /></td>
        </tr>
        <tr class="item">
            <td></td>
            <td colspan="5"><div class="lastboard"><a href="###" onclick="addrow(this, 1, {$vo.category_id})" class="addtr">{$Think.lang.add_new_category}</a></div></td>
        </tr>
        </case>
        <case value="2">
        <tr class="item">
            <td class="td25"><input type="text" class="txt" name="cateOrder[{$vo.category_id}]" value="{$vo.display_order}" /></td>
            <td><div class="board"><input type="text" name="cateName[{$vo.category_id}]" value="{$vo.name}" class="txt" /><a href="###" onclick="addrowdirect = 1;addrow(this, 2, {$vo.category_id})" class="addchildboard">{$Think.lang.add_sub_category}</a></div><div class="boardattr"></div></td>
            <td>{$vo.question_count}</td>
            <td>
                <notempty name="vo.moderators">
                <volist name="vo.moderators" id="sub" mod="2">
                    <eq name="mod" value="0">,&nbsp;&nbsp;</eq><a href="{$sub.user_id|format_user_url=$sub['username']}" target="_blank">{$sub.username}</a>
                </volist>
                <else/>
                {$Think.lang.no_moderator}
                </notempty>
            </td>
            <td>
                <a class="act" href="__URL__/moderator/category_id/{$vo.category_id}" title="{$Think.lang.manage_moderators}">{$Think.lang.category_moderators}</a>
                <a class="act" href="__URL__/edit/category_id/{$vo.category_id}">{$Think.lang.edit}</a>
                <a class="act" href="__URL__/delete/category_id/{$vo.category_id}">{$Think.lang.delete}</a>
            </td>
            <td><input type="checkbox" name="cateStatus[{$vo.category_id}]" value="1" <if condition="$vo.status eq '1'">checked</if> /></td>
        </tr>
        </case>
        <case value="3">
        <tr class="item">
            <td class="td25"><input type="text" class="txt" name="cateOrder[{$vo.category_id}]" value="{$vo.display_order}" /></td>
            <td><div id="cb_4" class="childboard"><input type="text" name="cateName[{$vo.category_id}]" value="{$vo.name}" class="txt" /></div><div class="boardattr"></div></td>
            <td>{$vo.question_count}</td>
            <td>
                <notempty name="vo.moderators">
                <volist name="vo.moderators" id="sub" mod="2">
                    <eq name="mod" value="0">,&nbsp;&nbsp;</eq><a href="{$sub.user_id|format_user_url=$sub['username']}" target="_blank">{$sub.username}</a>
                </volist>
                <else/>
                {$Think.lang.no_moderator}
                </notempty>
            </td>
            <td>
                <a class="act" href="__URL__/moderator/category_id/{$vo.category_id}" title="{$Think.lang.manage_moderators}">{$Think.lang.category_moderators}</a>
                <a class="act" href="__URL__/edit/category_id/{$vo.category_id}">{$Think.lang.edit}</a>
                <a class="act" href="__URL__/delete/category_id/{$vo.category_id}">{$Think.lang.delete}</a>
            </td>
            <td><input type="checkbox" name="cateStatus[{$vo.category_id}]" value="1" <if condition="$vo.status eq '1'">checked</if> /></td>
        </tr>
        </case>
        </switch>
        </volist>
        <tr class="item">
            <td></td>
            <td colspan="5"><div><a href="###" onclick="addrow(this, 0)" class="addtr">{$Think.lang.add_top_category}</a></div></td>
        </tr>
        <tr class="nobg">
            <td colspan="15"><div class="fixsel"><input type="submit" class="btn" value="{$Think.lang.submit}" /></div></td>
        </tr>
    </table>
    </form>
<div>

<include file="Public:footer" />
